package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.product.CategoryTreeFeignClient;
import com.atguigu.gmall.product.to.CategoryTreeTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @Author:lyd
 * @Date:2023/8/18 18:32
 * @Version:1.0
 * @Description
 **/
@Controller
public class IndexController {
    @Autowired
    private CategoryTreeFeignClient categoryTreeFeignClient;

    @GetMapping({"/","/index.html"})
    public String index(Model model) {
        Result<List<CategoryTreeTo>> categoryTree = categoryTreeFeignClient.getCategoryTree();
        List<CategoryTreeTo> data = categoryTree.getData();
        model.addAttribute("list",data);
        return "index/index";
    }
}
